#ifndef Algebra_MpiGroup_h
#define Algebra_MpiGroup_h

#include "AlgebraModule.h"
#include "mpi.h"

SG_NAMESPACE_OPEN
namespace Algebra
{
    /**
     * @brief An ordered collection of processes within a communicator.
     *
     * A group is an ordered set of process identiﬁers (henceforth processes); processes are
     * imple-mentation-dependent objects. Each process in a group is associated with an integer
     * rank.Ranks are contiguous and start from zero. Groups are represented by opaque group
     * ob-jects, and hence cannot be directly transferred from one process to another. A group
     * is used within a communicator to describe the participants in a communication “universe”
     * and to rank such participants (thus giving them unique names within that “universe” of
     * communication).
     *
     * @see MPI: A Message-Passing Interface Standard Version 4.0. 2021.
     *
     * @author nene
     * @date December, 2024.
     *
     */
    class ALGEBRA_EXPORT MpiGroup
    {
    public:
        MpiGroup (const MPI_Group& group);
        ~MpiGroup ();

        /// Return the rank of this process in the given group.
        int rank ();

        /// Return the size of a group.
        int size ();

    protected:
        MPI_Group mGroup; //< the underlying MPI group.
    };
}  // namespace Algebra

    SG_NAMESPACE_CLOSE

#endif  //  Algebra_MpiGroup_h